package awesome.cpu.structure;

import awesome.cpu.utils.Mode;

public class RegisterA extends SequentialComponent {
	
	private static boolean outputDebug = false;

	public final static int KEY_REGA_IN = 1;
	private int mRegAIn;
	
	public final static int KEY_REGA_OUT = 2;
	private int mRegAOut;
	
	private final static RegisterA mInstance = new RegisterA();
	
	private RegisterA() {}
	
	public static RegisterA getInstance() {
		return mInstance;
	}
	
	@Override
	void onClockTick() {
		mRegAOut = mRegAIn;
		if (outputDebug && Mode.getDebugLevel() >= Mode.DEBUG_LEVEL_PRINT_ALL) {
			System.out.println("RegA: A = " + mRegAOut);
		}
	}

	@Override
	boolean setData(int keyInterface, int data) {
		switch (keyInterface) {
		case KEY_REGA_IN:
			mRegAIn = data;
			return true;
		}
		return false;
	}

	@Override
	int getData(int keyInterface) {
		switch (keyInterface) {
		case KEY_REGA_OUT:
			return mRegAOut;
		}
		return 0;
	}
}
